package org.fengling.readingplatform.level.controller;


import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.fengling.readingplatform.level.service.LevelService;
import org.fengling.readingplatform.model.vo.common.Result;
import org.fengling.readingplatform.model.vo.common.ResultCodeEnum;
import org.fengling.readingplatform.model.vo.level.LevelVo;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/level")
public class LevelController {

    @Resource
    private LevelService levelService;

    @Operation(description = "获得经验值的方式")
    @PutMapping("/auth/getExperience")
    public Result getExp(Long experience){
        Long nowExp = levelService.getExperience(experience);
        return Result.build(nowExp, ResultCodeEnum.SUCCESS);
    }

    @Operation(description = "获得当前等级的方式")
    @GetMapping("/auth/getLevel")
    public Result getLevel(Long experience){
        String level = levelService.getLevel(experience);
        return Result.build(level, ResultCodeEnum.SUCCESS);
    }

    @Operation(description = "获取该等级所需要的经验值的方法")
    @GetMapping("/auth/getLevelInfo")
    public Result getLevelInfo(String level){
        LevelVo levelVo = levelService.getLevelInfo(level);
        return Result.build(levelVo, ResultCodeEnum.SUCCESS);
    }

}
